package com.seth.myapplication.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.seth.myapplication.R;

import java.util.List;

/**
 * Created by Seth on 2017/10/10.
 */

public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ItemHolder> {

    private Context mContext;
    private List<String> lists;
    private LayoutInflater inflater;

    public ItemAdapter(Context context, List<String> list){
        mContext = context;
        lists = list;
        inflater = LayoutInflater.from(context);
    }
    @Override
    public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {


        View view =  inflater.inflate(R.layout.item_recommend,parent,false);


        return new ItemHolder(view);
    }

    @Override
    public void onBindViewHolder(ItemHolder holder, int position) {
        String msg = lists.get(position);
        holder.bindText(msg);
    }

    @Override
    public int getItemCount() {
        return lists.size();
    }

    public static class ItemHolder extends RecyclerView.ViewHolder {
        private TextView mTextView;

        public ItemHolder(View itemView) {
            super(itemView);
            mTextView = (TextView) itemView.findViewById(R.id.item_task_content);
        }
        public void bindText(String mtext){
            mTextView.setText(mtext);
        }
    }
}
